const express = require("express");
const app = express();

app.get("/", (req, res) => {
    res.send("哈喽！express");
});

//get方式参数获取
app.get("/news", (req, res) => {
    let nid = req.query.nid;
    res.send("news模块，get参数：" + nid);
});

//restful路由
app.get("/news/:nid", (req, res) => {
    let nid = req.params["nid"];
    res.send("news模块，restful参数：" + nid);
});

app.post("/news", (req, res) => {
    res.send("This is POST request at /news");
});

app.put("/news", (req, res) => {
    res.send("This is PUT request at /news");
});

app.delete("/news", (req, res) => {
    res.send("This is DELETE request at /news");
});

app.listen(8080);